import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

//导入字体图标
import './assets/fonts/iconfont.css'
// 导入全局样式
import './assets/css/global.css'

// axios
import axios from 'axios'

//导入 NProgress
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import store from './store'

//请求的根路径
axios.defaults.baseURL = 'http://gz.pwbov.cn/'

//每次请求 在请求头 带 token 在 request 展示进度条
axios.interceptors.request.use(config => {
  NProgress.start()
  if (window.sessionStorage.getItem('token') != null) {
    config.headers.Authorization = 'Bearer' + ' ' + window.sessionStorage.getItem('token')
  }
  return config
})
// 在response 隐藏进度条
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

Vue.prototype.$http = axios

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
